package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.dto.DishDTO;
import com.sky.dto.DishPageQueryDTO;
import com.sky.entity.Dish;
import com.sky.entity.DishFlavor;
import com.sky.vo.DishVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;
import java.util.Map;

@Mapper
public interface DishMapper {

    /**
     * 根据分类id查询菜品数量
     * @param categoryId
     * @return
     */
    @Select("select count(id) from dish where category_id = #{categoryId}")
    Integer countByCategoryId(Long categoryId);

    void addDish(Dish dish);


    Page<DishVO> queryByPage(DishPageQueryDTO dishPageQueryDTO);

    void deleteDish(List<Long> ids);

    /**
     * 根据id查询菜品中的是否起售状态信息
     * @param id
     * @return
     */
    @Select("select * from dish where id=#{id}")
    Dish queryById(Long id);

    List<Dish> queryByClassificationId(Dish dish);

    /**
     * 菜品起售和停售
     * @param status
     * @param id
     */
    @Update("update dish set status=#{status} where id=#{id}")
    void startOrStop(Integer status, Long id);

    /**
     * 修改菜品时的数据回显
     * @param id
     * @return
     */
    @Select("select * from dish where id=#{id}")
    DishVO dataEcho(Long id);

    /**
     * 修改菜品
     * @param dish
     */
    void editDish(Dish dish);

    /**
     * 获取菜品总览
     * @param map
     * @return
     */
    Integer countByMap(Map map);
}
